package c15;

public class HelloThread extends Thread {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" hello");
    }

    /*
     * 在java中创建线程的方式有:
     * 1.继承Thread类
     * 2.实现Runnable接口
     */

    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+" start");
        HelloThread thread = new HelloThread();
        thread.start();

        Thread thread1 = new Thread(() -> {
            System.out.println(Thread.currentThread()+" hi");
        });
        thread1.start();
        /*
         * 线程的基本属性和方法:
         * join方法，等待线程执行结束：在main方法里调用thread.join()会等thread
         * 线程执行完成再执行main方法的线程
         */


    }
}
